package easy;

import java.util.ArrayList;
import java.util.List;

public class Solution_872 {

    public boolean leafSimilar(TreeNode root1, TreeNode root2) {
        List<Integer> list1 = new ArrayList<>();
        dps(root1, list1);
        List<Integer> list2 = new ArrayList<>();
        dps(root2, list2);
        if (list1.size()!=list2.size()) {
            return false;
        }
        for (int i = 0; i < list1.size(); i++) {
            if (list1.get(i) != list2.get(i)) {
                return false;
            }
        }
        return true;
    }

    private void dps(TreeNode node, List<Integer> list) {
        if (node==null) {
            return;
        }
        if (node.left==null && node.right==null) {
            list.add(node.val);
        }
        dps(node.left, list);
        dps(node.right, list);
    }

    public static void main(String[] args) {
        Solution_872 model = new Solution_872();
//        System.out.println(model.isRectangleOverlap(new int[]{0, 0, 2, 2}, new int[]{1, 1, 3, 3}));
//        System.out.println(model.isRectangleOverlap(new int[]{0, 0, 1, 1}, new int[]{1, 0, 2, 1}));
        System.out.println(Long.MAX_VALUE);
    }

    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode() {
        }

        TreeNode(int val) {
            this.val = val;
        }

        TreeNode(int val, TreeNode left, TreeNode right) {
            this.val = val;
            this.left = left;
            this.right = right;
        }
    }
}
